home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Controls / Visual Basic Controls.iso / vbcontrol / keyservh / mainform.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1999-08-20  |  5.0 KB  |  162 lines

  1. VERSION 5.00
  2. Begin VB.Form MainForm 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Service Test Harness"
  5.    ClientHeight    =   1545
  6.    ClientLeft      =   45
  7.    ClientTop       =   330
  8.    ClientWidth     =   4395
  9.    Icon            =   "MainForm.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    MaxButton       =   0   'False
  12.    ScaleHeight     =   1545
  13.    ScaleWidth      =   4395
  14.    StartUpPosition =   1  'CenterOwner
  15.    Begin VB.CommandButton Shutdown 
  16.       Caption         =   "Shutdown"
  17.       Enabled         =   0   'False
  18.       Height          =   375
  19.       Left            =   3360
  20.       TabIndex        =   6
  21.       Top             =   1080
  22.       Width           =   975
  23.    End
  24.    Begin VB.CommandButton Control 
  25.       Caption         =   "Control"
  26.       Enabled         =   0   'False
  27.       Height          =   375
  28.       Left            =   2280
  29.       TabIndex        =   5
  30.       Top             =   1080
  31.       Width           =   975
  32.    End
  33.    Begin VB.CommandButton PauseContinue 
  34.       Caption         =   "Pause"
  35.       Enabled         =   0   'False
  36.       Height          =   375
  37.       Left            =   1200
  38.       TabIndex        =   4
  39.       Top             =   1080
  40.       Width           =   975
  41.    End
  42.    Begin VB.CommandButton StartStop 
  43.       Caption         =   "Start"
  44.       Enabled         =   0   'False
  45.       Height          =   375
  46.       Left            =   120
  47.       TabIndex        =   3
  48.       Top             =   1080
  49.       Width           =   975
  50.    End
  51.    Begin VB.TextBox ProgId 
  52.       Height          =   285
  53.       Left            =   1440
  54.       TabIndex        =   2
  55.       Top             =   600
  56.       Width           =   2895
  57.    End
  58.    Begin VB.Label Label2 
  59.       Caption         =   "Specify the Prog ID of the ActiveX class you want to test."
  60.       Height          =   375
  61.       Left            =   120
  62.       TabIndex        =   0
  63.       Top             =   120
  64.       Width           =   4095
  65.    End
  66.    Begin VB.Label Label1 
  67.       Caption         =   "Service Prog ID:"
  68.       Height          =   255
  69.       Left            =   120
  70.       TabIndex        =   1
  71.       Top             =   600
  72.       Width           =   1215
  73.    End
  74. Attribute VB_Name = "MainForm"
  75. Attribute VB_GlobalNameSpace = False
  76. Attribute VB_Creatable = False
  77. Attribute VB_PredeclaredId = True
  78. Attribute VB_Exposed = False
  79. '****************************************************************************************************
  80. '   Copyright (c) Key Technology Pty Ltd 1999, All Rights Reserved.
  81. '   Web site: http://www.keytech.com.au  Email: info@keytech.com.au
  82. '****************************************************************************************************
  83. Option Explicit
  84. ' The service test harness may be used to test ActiveX controls that are to be
  85. ' hosted by the Service Host executable.
  86. Private ServiceObject As IService
  87. Private Sub ProgId_Change()
  88.     If StartStop.Caption = "Start" Then
  89.         StartStop.Enabled = (Len(ProgId) <> 0)
  90.     End If
  91. End Sub
  92. Private Sub StartStop_Click()
  93.     On Error Resume Next
  94.     If StartStop.Caption = "Start" Then
  95.         Set ServiceObject = CreateObject(ProgId)
  96.         
  97.         If Err Then
  98.             MsgBox "Failed to create service object. " & vbNewLine & _
  99.                    "Check that the ActiveX DLL is properly installed."
  100.             Exit Sub
  101.         End If
  102.         ServiceObject.OnStart
  103.         
  104.         If Err Then
  105.             MsgBox "OnStart failed - " & Err.Description
  106.         End If
  107.         
  108.         PauseContinue.Enabled = ServiceObject.Pausable
  109.         Control.Enabled = True
  110.         Shutdown.Enabled = True
  111.         
  112.         StartStop.Caption = "Stop"
  113.     Else
  114.         ServiceObject.OnStop
  115.         
  116.         If Err Then
  117.             MsgBox "OnStop failed - " & Err.Description
  118.         End If
  119.         
  120.         PauseContinue.Enabled = False
  121.         Control.Enabled = False
  122.         Shutdown.Enabled = False
  123.         
  124.         StartStop.Caption = "Start"
  125.     End If
  126. End Sub
  127. Private Sub PauseContinue_Click()
  128.     On Error Resume Next
  129.     If PauseContinue.Caption = "Pause" Then
  130.         ServiceObject.OnPause
  131.         
  132.         If Err Then
  133.             MsgBox "OnPause failed - " & Err.Description
  134.         End If
  135.         
  136.         PauseContinue.Caption = "Continue"
  137.     Else
  138.         ServiceObject.OnContinue
  139.         
  140.         If Err Then
  141.             MsgBox "OnContinue failed - " & Err.Description
  142.         End If
  143.         
  144.         PauseContinue.Caption = "Pause"
  145.     End If
  146. End Sub
  147. Private Sub Control_Click()
  148.     On Error Resume Next
  149.     ' OpCode must be within the range 128 to 255 inclusive
  150.     ServiceObject.OnControl 128
  151.     If Err Then
  152.         MsgBox "OnShutdown failed - " & Err.Description
  153.     End If
  154. End Sub
  155. Private Sub Shutdown_Click()
  156.     On Error Resume Next
  157.     ServiceObject.OnShutdown
  158.     If Err Then
  159.         MsgBox "OnShutdown failed - " & Err.Description
  160.     End If
  161. End Sub
  162.